/*
 * 人人信用管理有限公司版权所有.
 * 
 * @Description:
 * 
 * @author: liyuliang
 * 
 * @date: 20 Apr 2017 10:44:16 am
 * 
 * 注意：本内容仅限于人人信用管理有限公司内部传阅，禁止外泄以及用于其他的商业目的.
 */

package com.rrx360.common.web;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import com.rrx360.common.web.util.ResourceFunctions;

public class StartupShutdownListener implements ServletContextListener {

  public static final Logger logger = LogManager.getLogger(StartupShutdownListener.class);

  @Override
  public void contextInitialized(ServletContextEvent sce) {
    ResourceFunctions.setContext(sce.getServletContext().getContextPath());
    String realRoot = sce.getServletContext().getRealPath("");
    if (realRoot.endsWith("/")) {
      realRoot = realRoot.substring(0, realRoot.length() - 1);
    }
    ResourceFunctions.setRealRoot(realRoot);
    logger.info("ctx:" + ResourceFunctions.getCtx());
  }

  @Override
  public void contextDestroyed(ServletContextEvent sce) {

  }

}
